//
//  ZZThemeCell.m
//  ZZBlue
//
//  Created by stonesMonkey on 2017/9/21.
//  Copyright © 2017年 stonesMonkey. All rights reserved.
//

#import "ZZThemeCell.h"
#import "UIImage+ZUtilities.h"
#import "ZZColorRGBA.h"

@interface ZZThemeCell()

@property (weak, nonatomic) IBOutlet UIButton *aBtn;

@property (weak, nonatomic) IBOutlet UIButton *bBtn;

@property (weak, nonatomic) IBOutlet UIImageView *imgView;

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;




@end

@implementation ZZThemeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    self.aBtn.layer.cornerRadius = 16;
    self.bBtn.layer.cornerRadius = 16;
}


- (void)setModel:(ZZThemeCellModel *)model {
    
    _model = model;
    self.titleLabel.text = model.title;
    [self.imgView setImage:[UIImage imageNamed:model.imageStr]];
    self.imgView.image = [self.imgView.image imageWithColors: [self nativeColors:model.colors]];
}

#pragma mark - action
- (IBAction)aClick:(id)sender {
    
}

- (IBAction)bClick:(id)sender {
    
}

- (IBAction)settingClick:(id)sender {
    
    if (self.setBtnDidClick) {
        
        self.setBtnDidClick(self.model);
    }
}

#pragma mark - nativeColors
- (NSArray <UIColor *>*)nativeColors:(NSArray <ZZColorRGBA *>*)colors {
    
    NSMutableArray *mtbArr = [NSMutableArray array];
    for (NSInteger index = 0; index < colors.count; index ++) {
        
        ZZColorRGBA *rgba = colors[index];
        UIColor *color = [UIColor zColorWithRed:rgba.R green:rgba.G blue:rgba.B];
        [mtbArr addObject:color];
    }
    
    return [mtbArr copy];
}




@end
